<div class="box-body">
    <form class="layui-form" action="{:url('save')}" method="post">
        <div class="layui-form-item">
            <label class="layui-form-label xrequired">平台</label>
            <div class="layui-input-block">
                {if isset($account)}
                <input type="text" style="border: 0px;" readonly class="layui-input" value="{$account.platform.name}">
                <input type="hidden" name="platform_id" value="{$account.platform_id}"/>
                {else}
                <select name="platform_id" lay-search>
                    <option value="">请选择</option>
                    {foreach $platform as $p}
                    <option value="{$p.platform_id}">{$p.name}</option>
                    {/foreach}
                </select>
                {/if}
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label xrequired">账号</label>
            <div class="layui-input-block">
                <input type="text" autocomplete="off" name="username" class="layui-input" {if isset($account)}value="{$account.username}"{/if}>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label xrequired">店铺名</label>
            <div class="layui-input-block">
                <input type="text" autocomplete="off" name="store_name" class="layui-input" {if isset($account)}value="{$account.store_name}"{/if}>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">站点</label>
            <div class="layui-input-block">
                <div id="site-xm-select" {if isset($account)}value="{$account->getData('site')}"{/if} name="site"></div>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">发货天数</label>
            <div class="layui-input-block">
                <input type="number" autocomplete="off" name="send_day" class="layui-input" {if isset($account)}value="{$account.send_day}"{/if}>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">税号</label>
            <div class="layui-input-block">
                <input type="text" autocomplete="off" name="tax_num" class="layui-input" {if isset($account)}value="{$account.tax_num}"{/if}>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-block">
                <input type="number" autocomplete="off" name="sort" class="layui-input" {if isset($account)}value="{$account.sort}"{/if}>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <input type="text" autocomplete="off" name="remark" class="layui-input" {if isset($account)}value="{$account.remark}"{/if}>
            </div>
        </div>
        {if isset($tokenField)}
        {foreach $tokenField['required'] as $r}
        {php}$field=$r['field'];{/php}
        <div class="layui-form-item">
            <label class="layui-form-label xrequired">{$r.name}</label>
            <div class="layui-input-block">
                {if $r.type == 'select'}
                    <select name="token_{$r.field}">
                        <option value="">请选择</option>
                        {foreach $r['value'] as $k=>$v}
                        <option {if isset($account->token->$field) && $account->token->$field == $k}selected{/if} value="{$k}">{$v}</option>
                        {/foreach}
                    </select>
                {else}
                    <input type="text" {if isset($r['readonly']) && $r['readonly']}readonly style="border: 0px;"{/if} name="token_{$r.field}" {if isset($account->token->$field)}value="{$account->token->$field}"{/if} placeholder="密钥可为空，若填一项带星号的都必填" class="layui-input">
                {/if}
            </div>
        </div>
        {/foreach}
        {foreach $tokenField['option'] as $r}
        {php}$field=$r['field'];{/php}
        <div class="layui-form-item">
            <label class="layui-form-label">{$r.name}</label>
            <div class="layui-input-block">
                {if $r.type == 'select'}
                <select name="token_{$r.field}">
                    <option value="">请选择</option>
                    {foreach $r['value'] as $k=>$v}
                    <option {if isset($account->token->$field) && $account->token->$field == $k}selected{/if} value="{$k}">{$v}</option>
                    {/foreach}
                </select>
                {else}
                <input type="text" {if isset($r['readonly']) && $r['readonly']}readonly style="border: 0px;"{/if} name="token_{$r.field}" {if isset($account->token->$field)}value="{$account->token->$field}"{/if} placeholder="可不填" class="layui-input">
                {/if}
            </div>
        </div>
        {/foreach}
        {/if}
        {if isset($account)}
        <input type="hidden" name="account_id" value="{$account.account_id}">
        {/if}
    </form>
</div>
<script type="text/javascript">
    $("#render-site").click();
</script>